package com.app.web.adimin.model;

import java.util.ArrayList;
import java.util.List;

import com.app.web.BaseModel;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;
/***
 * 
 * 
 * @author Administrator
 */
public class Menu extends BaseModel<Menu>{

	private static final long serialVersionUID = -6752858086487177427L;
	public static final Menu dao = new Menu();
	
	public List<Menu> findMenuByIds(String ids){
		if(StrKit.notBlank(ids)){
			return dao.find("select * from menu where id in("+ids+") order by id asc" );
		}
		return null;
	}
	public List<Record> getMenuTree(List<Menu> list){
		if(list!=null){
			//return this.listToTree(list, "id", "parent_id", 2);
			return this.listTree(list, "id", "parent_id", 2);
		}
		return new ArrayList<Record>();
	}
	public List<Menu> findMenuById(int id){
		return dao.find("select * from menu where id>="+id+" order by id asc" );
	}
	
}
